realtek: pcs: move polarity into SerDes struct
authorJonas Jelonek <[email protected]>
Thu, 11 Dec 2025 23:33:59 +0000 (23:33 +0000)
committerRobert Marko <[email protected]>
Tue, 16 Dec 2025 12:37:32 +0000 (13:37 +0100)
As a first real usage of the new SerDes struct, move the polarity
configuration there. It was previously located in the global rtpcs_ctrl
struct as an array, indexed by SerDes id. Because this is per-SerDes
information, the new SerDes struct is the correct place to live in.

Signed-off-by: Jonas Jelonek <[email protected]>
Link: https://github.com/openwrt/openwrt/pull/21146
Signed-off-by: Robert Marko <[email protected]>
target/linux/realtek/files-6.12/drivers/net/pcs/pcs-rtl-otto.c

index 7c0f737a67975b438bb1c366e968ca97755d32e8..0a1d994da7a108cc0894290f84a0bb23c71c1ea4 100644 (file)
@@ -135,6 +135,9 @@ struct rtpcs_serdes {
        struct rtpcs_ctrl *ctrl;
        u8 id;
        enum rtpcs_sds_mode mode;
+
+       bool rx_pol_inv;
+       bool tx_pol_inv;
 };
 
 struct rtpcs_ctrl {
@@ -144,8 +147,6 @@ struct rtpcs_ctrl {
        const struct rtpcs_config *cfg;
        struct rtpcs_serdes serdes[RTPCS_SDS_CNT];
        struct rtpcs_link *link[RTPCS_PORT_CNT];
-       bool rx_pol_inv[RTPCS_SDS_CNT];
-       bool tx_pol_inv[RTPCS_SDS_CNT];
        struct mutex lock;
 };
 
@@ -2242,8 +2243,7 @@ static int rtpcs_930x_setup_serdes(struct rtpcs_serdes *sds,
        pr_info("%s: Configuring RTL9300 SERDES %d\n", __func__, sds->id);
 
        /* Set SDS polarity */
-       rtpcs_930x_sds_set_polarity(sds, sds->ctrl->tx_pol_inv[sds->id],
-                                   sds->ctrl->rx_pol_inv[sds->id]);
+       rtpcs_930x_sds_set_polarity(sds, sds->tx_pol_inv, sds->rx_pol_inv);
 
        /* Enable SDS in desired mode */
        rtpcs_930x_sds_mode_set(sds, phy_mode);
@@ -2831,8 +2831,7 @@ static int rtpcs_931x_setup_serdes(struct rtpcs_serdes *sds,
                }
        }
 
-       rtpcs_931x_sds_set_polarity(sds, ctrl->tx_pol_inv[sds_id],
-                                   ctrl->rx_pol_inv[sds_id]);
+       rtpcs_931x_sds_set_polarity(sds, sds->tx_pol_inv, sds->rx_pol_inv);
 
        val = ori & ~BIT(sds_id);
        regmap_write(ctrl->map, RTL931X_PS_SERDES_OFF_MODE_CTRL_ADDR, val);
@@ -3090,8 +3089,9 @@ static int rtpcs_probe(struct platform_device *pdev)
                if (sds_id >= ctrl->cfg->serdes_count)
                        return -EINVAL;
 
-               ctrl->rx_pol_inv[sds_id] = of_property_read_bool(child, "realtek,pnswap-rx");
-               ctrl->tx_pol_inv[sds_id] = of_property_read_bool(child, "realtek,pnswap-tx");
+               sds = &ctrl->serdes[sds_id];
+               sds->rx_pol_inv = of_property_read_bool(child, "realtek,pnswap-rx");
+               sds->tx_pol_inv = of_property_read_bool(child, "realtek,pnswap-tx");
        }
 
        if (ctrl->cfg->init_serdes_common) {